package worldinruin.core.soldiers;

import static org.junit.Assert.*;

import org.junit.Test;

import worldinruin.core.ITile;
import worldinruin.core.imp.Troop;
import worldinruin.core.imp.soldiers.Archer;
import worldinruin.core.imp.soldiers.Catapult;
import worldinruin.core.imp.soldiers.Cavalier;
import worldinruin.core.imp.tilemodels.GrassTile;
import worldinruin.core.imp.tilemodels.StoneTile;

public class TroopTest {

	@Test
	public void testRemove() {
		Troop t = new  Troop();
		
		t.add(new Cavalier(), 5);
		
		
		assertTrue(t.remove(new Cavalier(), 3) == 3);
		assertTrue(t.remove(new Cavalier(), 10) == 2);
	}

	@Test
	public void testAdd() {
		Troop t = new  Troop();
		
		t.add(new Cavalier(), 5);
		t.add(new Cavalier(), 3);
		
		assertTrue(t.getAmount(new Cavalier()) == 8);
		assertTrue(t.getAmount(new Archer()) == 0);
	}

	@Test
	public void testMerge() {
		Troop t = new  Troop();
		Troop t2 = new Troop();
		
		t.add(new Cavalier(), 4);		
		t2.add(new Cavalier(), 3);
		
		t.merge(t2);
		
		assertTrue(t.getAmount(new Cavalier()) == 0);
		assertTrue(t2.getAmount(new Cavalier()) == 7);
		
		
	}
	
	@Test
	public void testIsDefeated(){
		Troop t = new Troop();
		
		t.add(new Archer(), 5);
		t.add(new Catapult(), 3);
		
		assertTrue(!t.isDefeated());
		
		t.remove(new Archer(), 5);
		
		assertTrue(!t.isDefeated());
		
		t.remove(new Catapult(), 3);
		
		assertTrue(t.isDefeated());
		
	
	}
	


}
